home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C06 / Stack3Test.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  792 b   |  31 lines

  1. //: C06:Stack3Test.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. //{L} Stack3
  7. // Constructors/destructors
  8. #include "Stack3.h"
  9. #include "../require.h"
  10. #include <fstream>
  11. #include <iostream>
  12. #include <string>
  13. using namespace std;
  14.  
  15. int main(int argc, char* argv[]) {
  16.   requireArgs(argc, 1); // File name is argument
  17.   ifstream in(argv[1]);
  18.   assure(in, argv[1]);
  19.   Stack textlines;
  20.   string line;
  21.   // Read file and store lines in the stack:
  22.   while(getline(in, line))
  23.     textlines.push(new string(line));
  24.   // Pop the lines from the stack and print them:
  25.   string* s;
  26.   while((s = (string*)textlines.pop()) != 0) {
  27.     cout << s << endl;
  28.     delete s; 
  29.   }
  30. } ///:~
  31.